/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
 var isAnagram = function(s, t) {
  let hash = {}
  for(let i of s){
    if(hash[i] === undefined){
      hash[i] = 1
    }else{
      hash[i]++
    }
  }
  for(let i of t){
    console.log(hash[i]);
    if(hash[i]){
      hash[i]--
    }else{
      return false
    }
  }
  for(let i in hash){
    if(hash[i]) return false
  }
  
  return true
};
console.log(isAnagram("anagram",
"nagara"));